import UI_Notice from "../../ui/Main/UI_Notice";
import BaseUIMediator from "../../LTGame/UI/BaseUIMediator";

export default class UI_NoticeMediator extends BaseUIMediator<UI_Notice> {

    private static _instance: UI_NoticeMediator;
    public static get instance(): UI_NoticeMediator {
        if (this._instance == null) {
            this._instance = new UI_NoticeMediator();
            this._instance._classDefine = UI_Notice;
        }
        return this._instance;
    }

    private _cacheData: NoticeData;

    _OnPreShow() {
        this._uiData.isFullScreen = true;
    }

    _OnShow() {
        super._OnShow();
        // your code

        this._cacheData = this._openParam;
        this.ui.m_view.m_view_title.m_text_value.text = this._cacheData.title;
        this.ui.m_view.m_text_notice.text = this._cacheData.context;

        this.ui.m_view.m_btn_confirm.onClick(this, this._OnClickConfirm);
    }

    private _OnClickConfirm() {
        this.Hide();
        if (this._cacheData.onClose != null) {
            this._cacheData.onClose.run();
        }
    }

}

export class NoticeData {

    title: string = '提示';
    context: string = '提示内容';
    onClose: Laya.Handler = null;

}